package com.demo.simpletestapp.utils

import android.graphics.Outline
import android.view.View
import android.view.ViewOutlineProvider
import android.widget.ImageView

class ViewUtils(var radius:Int = 32) {
     // 圆角半径
     private val viewOutlineProvider = object : ViewOutlineProvider() {
        override fun getOutline(view: View?, outline: Outline?) {
            outline?.setRoundRect(0, 0, view?.width ?: 0, view?.height ?: 0, radius.toFloat())
        }
    }

    fun showRoundImage(imageView: ImageView){
        imageView.outlineProvider = viewOutlineProvider
        imageView.clipToOutline = true
    }

    fun showRoundImage(imageView: View){
        imageView.outlineProvider = viewOutlineProvider
        imageView.clipToOutline = true
    }
}